A letter of the English
alphabet is given. Print its previous and next letter.
Input. One letter ñ (‘A’ < c < ‘Z’ or ‘a’ < c < ‘z’) of the English
alphabet (lowercase or uppercase).
Output. Print the letter
that precedes c, followed by the letter that comes after c in the
English alphabet (preserving the case).
Sample input 1 |
Sample output 1 |
D |
C E |
|
|
Sample input 2 |
Sample output 2 |
X |
w y |
chars
Let c be the input character. Print the characters c – 1 and c + 1.
Algorithm
realization
Read the input symbol c.
scanf("%c", &c);
Print the symbols c – 1 and c + 1.
printf("%c %c\n", c - 1, c + 1);
Python realization
Read the input symbol c.
c = input()
Compute and print the
symbols prev = c – 1 and next
= c + 1.
prev = chr(ord(c) - 1)
next = chr(ord(c) + 1)
print(prev, next)